package org.rbac.serv;

import org.apache.log4j.Logger;
import org.rbac.po.PermissionSyslog;
import org.springframework.stereotype.Service;

import com.kingschan.lang.date.TimeStampUtil;

@Service("LogServices")
public class LogServices extends CommonServices {

    Logger log = Logger.getLogger(LogServices.class);
    /**
     * 日志记录
     * @param ip
     * @param method
     * @param uri
     * @param uid
     * @param data
     * @param remark
     * @param pass
     * @param seconds
     * @return
     */
    public Boolean log(String ip,String method,String uri,Integer uid,String data,String remark,boolean pass,long seconds,String referer) {
        boolean flag=false;
       try {
           PermissionSyslog log = new PermissionSyslog();
           log.setSlUid(uid);
           log.setSlCdate(TimeStampUtil.getCurrentDate());
           log.setSlData(data);
           log.setSlIp(ip);
           log.setSlMethod(method);
           log.setSlMseconds(seconds);
           log.setSlPass(pass);
           log.setSlRemark(remark);
           log.setSlUri(uri);
           log.setSlReferer(referer);
           getDao().save(log);
           flag= true;
        } catch (Exception e) {
            e.printStackTrace();
            log.error(e);
        }
        return flag;
    }
}
